package org.yantsu.loadtestanalyzer.ltaweb;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class Delete extends HttpServlet {
	private static final long serialVersionUID = -6353838648102104450L;
	private ElasticSearchClient esClient;

	@Override
	public void init() throws ServletException {
		WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
		esClient = ctx.getBean(ElasticSearchClient.class);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		esClient.deleteSeries(req.getParameter("series"));
	}
}
